package com.hzw.rest;

import com.hzw.api.IReserveService;
import com.hzw.entity.Reserve;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@CrossOrigin
@RequestMapping("reserve")
public class Reservecontroller {

    @Autowired
    IReserveService reserveService;

    /**
     * 新增预定
     * @param reserve
     * @return
     */
    @PostMapping("insert")
    @ResponseBody
    public int insert(@RequestBody Reserve reserve){
        return reserveService.insert(reserve);
    }

    /**
     * 查询预定
     * @param reserve
     * @return
     */
    @PostMapping("select")
    @ResponseBody
    public List<Reserve> select(@RequestBody Reserve reserve){
        return reserveService.select(reserve);
    }

    /**
     * 用户添加预定
     * @param reserve
     * @return
     */
    @PostMapping("updateAdd")
    @ResponseBody
    public void updateAdd(@RequestBody Reserve reserve){
        reserveService.updateAdd(reserve);
    }

    /**
     * 用户取消预定
     * @param reserve
     * @return
     */
    @PostMapping("updateDel")
    @ResponseBody
    public void updateDel(@RequestBody Reserve reserve){
        reserveService.updateDel(reserve);
    }

    /**
     * 商家删除预定
     * @param reserve
     * @return
     */
    @PostMapping("delete")
    @ResponseBody
    public void delete(@RequestBody Reserve reserve){
        reserveService.delById(reserve);
    }
}
